package com.example.demo.controller;

import java.util.List;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.config.Result;
import com.example.demo.entity.Bayonet;
import com.example.demo.entity.Point;
import com.example.demo.service.HbaseCarsMessageService;

import io.swagger.annotations.Api;

/**
 *  从hbase获取交运治理场景车辆信息
 * @author admin
 *
 */
@Api(value = "restApi入口")
@RestController
@RequestMapping("info")
public class HbaseCarsMessageController {
	
	@Autowired
	private HbaseCarsMessageService hbaseCarsMessageService;
	@ApiOperation(value = "获取车辆经过卡口的信息")
	@GetMapping("/bayonet")
	public Result<?> getCarPassedBayonetInformation(@RequestParam("licenseNumber")String licenseNumber,
													@RequestParam(value = "type" , required = false) String type,
													@RequestParam("startTime")String startTime,
													@RequestParam("endTime")String endTime) {
		return Result.OK(this.hbaseCarsMessageService.getCarPassedBayonetInformation(licenseNumber, startTime, endTime, type));
	} 

	@ApiOperation(value="获取所有卡口信息")
	@GetMapping("/all/bayonet")
	public Result<?> getAllBayonetInformation() {
		return  Result.OK(this.hbaseCarsMessageService.getAllBayonetInformation());
	}

	@GetMapping("point/coordinate/bayonet")
	public Result<?> getPointCoordinateBayonetInformation(@RequestBody List<Point> points) {
		if (points.size() <= 2) {
			return Result.error("经纬度个数必须大于等于3对");
		}
		return Result.OK(this.hbaseCarsMessageService.getPointCoordinateBayonetInformation(points));
	} 
	
	@GetMapping("national/highWay/bayonet")
	public Result<?> getNationalAndHighWayinateBayonetInformation() {
		return Result.OK(this.hbaseCarsMessageService.getNationalAndHighWayinateBayonetInformation());
	} 
	
	@GetMapping("type/bayonets")
	public Result<?> getTypeBayonetsInformation(@RequestParam("startTime")String startTime,
												@RequestParam("endTime")String endTime,
												@RequestParam(value = "type" , required = false) String type,
												@RequestBody List<Bayonet> list) {
		return Result.OK(this.hbaseCarsMessageService.getTypeBayonetsInformation(startTime,endTime,type,list));
	}
	
	@GetMapping("lease/bayonets")
	public Result<?> getLeaseBayonetsInformation(@RequestParam("startTime")String startTime,
												@RequestParam("endTime")String endTime,
												@RequestParam(value = "type" , required = false) String type,
												@RequestBody List<Bayonet> list) {
		return Result.OK(this.hbaseCarsMessageService.getLeaseBayonetsInformation(startTime,endTime,type,list));
	}
}
